#ifndef __URL_PARSE_H__
#define __URL_PARSE_H__

#include "errordef.h"

#define E_ILLEGAL_URL E_USER


const char* GetFirstNonSpace(const char* s);

/* 
 * if in the url, there is no explicit port information, m_port is zero.
 * for example: http://www.google.com
 */
class CURLParser
{
public:
   CURLParser();
   virtual ~CURLParser();
   
public:
   int Parse(const char* url);
   
protected:
   int GetScheme (const char* url, char const ** domain);
   int SetDefaultScheme();
   int GetDomain (const char* domain, char const ** port);
   int GetPort(const char* port, char const ** path);
   int GetPathAndAnchor(const char* path);
   void FreeMem();
   
public:
   char* m_scheme;
   char* m_domain;
   unsigned int m_port;
   char* m_path;
   char* m_anchor;
   char* m_url;
};

#endif /* __URL_PARSE_H__ */
